package com.wbcs.jbsf.interceptor;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.wbcs.config.component.application.report.ColBean;
import com.wbcs.config.component.application.report.ReportBean;
import com.wbcs.jbsf.util.Consts;
import com.wbcs.jbsf.util.Wbcs4JBSFUtil;
import com.wbcs.system.ReportRequest;
import com.wbcs.system.assistant.ReportAssistant;
import com.wbcs.system.component.application.report.abstractreport.AbsReportType;
import com.wbcs.system.intercept.AbsInterceptorDefaultAdapter;

public class ItprLoadata2Req extends AbsInterceptorDefaultAdapter
{
    @Override
	public Object afterLoadData(ReportRequest rrequest,ReportBean rbean,Object typeObj,Object dataObj)
    {
        if(typeObj instanceof AbsReportType){
            Object vo = ((List)dataObj).get(0);
            HttpServletRequest request = rrequest.getRequest();
            List<ColBean> lstColBean = rbean.getDbean().getLstCols();
            for(int i=0;i<lstColBean.size();i++)
            {
                String colname = lstColBean.get(i).getColumn();
                //request.setAttribute(colname,ReportDataAssistant.getInstance().getColValue(rrequest,rbean.getId(),colname,vo));
                request.setAttribute(colname,ReportAssistant.getInstance().getPropertyValue(vo, colname));
            }
            
            //编辑退回不能再显示推送要闻按钮
            String rolename = Wbcs4JBSFUtil.getRolenames(rrequest.getRequest().getSession().getAttribute(com.wbcs.jbsf.util.Consts.SESSION_ROLE));
            //Object xwzt = ReportDataAssistant.getInstance().getColValue(rrequest,rbean.getId(),"xwzt",vo);
            Object xwzt = ReportAssistant.getInstance().getPropertyValue(vo, "xwzt");
            if(rolename.indexOf("编辑") != -1 && Consts.FLOW_GOBACK.equals(xwzt)){
                rrequest.authorize(rbean.getId(), com.wbcs.util.Consts.BUTTON_PART, "toimpttnewsCstmBtn", "display", "false");
            }
        }
        
        return dataObj;
    }
}

